package com.sikaryofficial.backend.loader;

import com.sikaryofficial.backend.annotation.TenantFilter;
import com.sikaryofficial.backend.service.article.cache.ReceivedLikesCacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @author : qinjinyuan
 * @desc : 收到的点赞缓存预加载
 * @date : 2024/04/27 14:29
 */
@Component
@Slf4j
public class ReceivedLikesLoader implements CommandLineRunner {
    @Autowired
    private ReceivedLikesCacheService receivedLikesCacheService;
    @Value("${hismk.backend.loader.received}")
    private boolean loadFlag ;
    @Override
    @TenantFilter
    public void run(String... args) {
        if (Boolean.TRUE.equals(loadFlag)) {
            log.info("start: 收到的点赞缓存预加载=================================");
            receivedLikesCacheService.loadData();
            log.info("end: 收到的点赞缓存预加载=================================");
        }
    }
}
